/*
 *		source/preferences/preferences.js - Preferences
 */

/* Tegi's Commander - A file manager for Palm WebOS
 * Copyright (C) 2011 Timo Tegtmeier
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

enyo.kind({
	name:			"PreferencesDialog",
	kind:			"ModalDialog",
	layoutKind:		"VFlexLayout",
	contentHeight:	"100%",
	lazy:			false,

	prefs:			null,

	components:	[{
		content:	$L("Preferences"),
		style:		"font-weight: bold; font-size: 18px; margin-bottom: 0px;"
	}, {
		kind:		"RowGroup",
		caption:	$L("File listing"),
		components:	[{
			name:		"showHiddenFiles",
			kind:		"ToggleItem",
			caption:	$L("Show hidden files")
		}]
	}, {
		kind:		"RowGroup",
		caption:	$L("Quick actions"),
		components:	[{
			name:		"showCreateFile",
			kind:		"ToggleItem",
			caption:	$L("Direct file creation")
		}, {
			name:		"showGotoFolder",
			kind:		"ToggleItem",
			caption:	$L("Direct folder selection")
		}]
	}, {
		kind:		"Button",
		className:	"enyo-button-affirmative",
		caption:	$L("OK"),
		onclick:	"okClicked"
	}],

	okClicked: function(sender, event) {
		this.prefs.showGotoFolder = this.$.showGotoFolder.getValue();
		this.prefs.showCreateFile = this.$.showCreateFile.getValue();
		this.prefs.showHiddenFiles = this.$.showHiddenFiles.getValue();

		this.close();
		this.owner.settingsChanged(this.prefs);
	},

	create: function() {
		this.inherited(arguments);
		this.prefs = this.owner.getSettings();
		this.$.showGotoFolder.setValue(this.prefs.showGotoFolder);
		this.$.showCreateFile.setValue(this.prefs.showCreateFile);
		this.$.showHiddenFiles.setValue(this.prefs.showHiddenFiles);
	}
});
